package samples.d3.color 
{
	import color.HSL;
	import color.RGB;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.utils.setInterval;
	import graphics.pattern.Hachage;
	import samples.BaseSample;
	import shapes.shapes2D.BaseShape;
	import shapes.shapes2D.Circle;
	import shapes.shapes2D.curves.Spiral;
	import shapes.shapes2D.distribution.goldenRatio.GoldenRatio;
	import shapes.shapes2D.distribution.random.PRNG;
	import shapes.shapes2D.polygon.RegularPolygon;
	import shapes.shapes2D.Quad;
	
	/**
	 * @author Nicolas Barradeau
	 * http://en.nicoptere.net
	 */
	public class Color5 extends BaseSample 
	{
		
		private var hsl:HSL;
		private var hue:int = 60;
		private var angle:Number = 0;
		private var shapes:Vector.<BaseShape>;
		
		public function Color5() 
		{
			
			hsl = new HSL( hue );
			
			var bd:BitmapData = new BitmapData( 250, 350, true, 0 );
			var bmp:Bitmap = new Bitmap( bd, 'auto', true );
			
			addChild( bmp );
			bmp.x = 260;
			
			PRNG.seed = 0xFFF;
			Hachage.process( bd, 1000 );
			
			var w:int = 250;
			var h:int = 350;
			
			var p0:Point = new Point( 0, 0 );
			var p1:Point = new Point( w, 0 );
			var p2:Point = new Point( w, h );
			var p3:Point = new Point( 0, h );
			
			var vertices:Vector.<Number> = Vector.<Number>( [ p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y ] );
			var uvs:Vector.<Number> = Vector.<Number>( [ 0,0, 1,0, 1,1, 0,1 ] );
			var indices:Vector.<int> = Vector.<int>( [ 0,1,3, 1,2,3 ] );
			graphics.lineStyle( 0, 0 );
			graphics.beginBitmapFill( bd, null, false, true );
			graphics.drawTriangles( vertices, indices, uvs );
			
			center();
			
		}
		
		
		public function getColor():uint 
		{
			hsl.hue += 0.01;
			return hsl.toHex();
		}
	}

}
